﻿<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page isELIgnored="false" %> 

<%@ page import="net.ssta.core.db.RecordSet"%>
<%@ page import="net.ssta.core.db.Record"%>
<%@page import="net.ssta.core.web.RequestKit"%>
<%@ page import="net.ssta.core.db.PagingInfo"%>

<%
	String path = request.getContextPath();
	//分页参数
    PagingInfo pagingInfo =(PagingInfo) request.getAttribute("pagingInfo");
    int pageno = pagingInfo.getCurrentPageNo();
    
    Record searchRcd = (Record) request.getAttribute("searchRcd");
    
    //科技成果信息列表
    RecordSet kjcgInfoSet = (RecordSet) request.getAttribute("kjcgInfoSet");
    
    //成果类别
    RecordSet cblb = (RecordSet) request.getAttribute("cglb");
    
    //代码、值Map
    Map fildOptionMap =  (HashMap)request.getAttribute("fildOptionMap");
    
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<link type="text/css" rel="stylesheet" href="<%=path%>/includes/css/commonStyle.css"/> 
<link type="text/css" rel="stylesheet" href="<%=path%>/includes/styleBase/css/styleBase.css"/>
<link type="text/css" rel="stylesheet" href="<%=path%>/includes/styleBase/css/ostable.css" />
<link type="text/css" rel="stylesheet" href="<%=path%>/includes/styleBase/css/tab.css" />
<link rel="stylesheet" href="<%=path%>/includes/lhgdialog/lhgdialog.css" />



<script type='text/javascript' src="<%=path%>/includes/js/jquery.js"></script>
<script type="text/javascript" src="<%=path%>/includes/styleBase/js/style.js"></script>
<script type="text/javascript" src="<%=path%>/includes/DatePicker/WdatePicker.js"></script>


<script type="text/javascript" src="<%=path%>/includes/lhgdialog/lhgcore.min.js"></script>
<script type="text/javascript" src="<%=path%>/includes/lhgdialog/lhgdialog.js"></script>

<title>项目需求后台管理</title>
 
<script type="text/javascript">
$("document").ready(function()
{
	 
}); 

function moreSearch()
{
	$('#more').show();
	$('#more1').show();
	$('#moreButton').hide();
	$('#lessButton').show();
}

function lessSearch()
{
	$('#more').hide();
	$('#more1').hide();
	$('#moreButton').show();
	$('#lessButton').hide();
}

function handle()
{
	
	//var length =  $("input[type=checkbox]").length;
	
	var ids= $("input[type='checkbox']");
	var length = 0;
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			length++;
		}
	}
	
	if(length==0)
	{
		alert("请至少一条记录进行操作");
		return;
	}
	
	
	var pids="";
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			pids=pids+ids[i].value+',';  //如果选中，将value添加到变量pids中
		}
	}
	
	var dlg = new J.ui.dialog({ id:'handlekjcgdemand',
		                         title:'处理项目需求',
		                         range:true,
		                         btns:true,
		                         page:'<%=path%>/back/userNeeds/HandleKjcgNeeds.jsp?kjcgUuids='+pids,
		                         width:700,
		                         height:400,
		                         windowObj:window});
	dlg.ShowDialog();
}




function onHandle()
{
	
	//var length =  $("input[type=checkbox]").length;
	
	var ids= $("input[type='checkbox']");
	var length = 0;
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			length++;
		}
	}
	
	if(length==0)
	{
		alert("请至少一条记录进行操作");
		return;
	}
	
	
	var pids="";
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			pids=pids+ids[i].value+',';  //如果选中，将value添加到变量pids中
		}
	}
	
     $.ajax({
			type: "POST", url: "<%=path%>/back/UserNeedsManage?method=unHandKjcgNeeds&kjcgUuids="+pids,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function(msg){
				alert("操作成功!");
				_goPage(<%=pageno%>);
			}
	 });
	
}



function deleteKjcgNeed()
{
	var ids= $("input[type='checkbox']");
	var length = 0;
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			length++;
		}
	}
	
	if(length==0)
	{
		alert("请至少一条记录进行操作");
		return;
	}
	
	
	var pids="";
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			pids=pids+ids[i].value+',';  //如果选中，将value添加到变量pids中
		}
	}
	
	
	$.ajax({
			type: "POST", url: "<%=path%>/back/UserNeedsManage?method=deleteKjcgUserNeeds&kjcgUuids="+pids,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function(msg){
				alert("操作成功!");
				_goPage(<%=pageno%>);
			}
	 });
}





function changeKjcgStatus(fieldname,status){
	
	var ids= $("input[type='checkbox']");
	var length = 0;
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			length++;
		}
	}
	
	if(length==0)
	{
		alert("请至少一条记录进行操作");
		return;
	}
	
	
	var pids="";
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			pids=pids+ids[i].value+',';  //如果选中，将value添加到变量pids中
		}
	}
	
	$.ajax({
			type: "POST", url: "<%=path%>/back/InfoRecommend?method=changeKjcgStatus&kjcgUuids="+pids+"&fieldName="+fieldname+"&status="+status,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function(msg){
				alert("操作成功!");
				_goPage(<%=pageno%>);
			}
	 });
}



function doSearch()
{
	var form = document.getElementById("seaForm");
	form.submit();
}

//跳转
function reloadPage() 
{
	_goPage(<%=pageno%>);
}


function _selectall(){
	var uuids = document.getElementsByName("uuids");
	if(uuids.length){
		for(var i=0;i<uuids.length;i++){
			uuids[i].checked = document.getElementById("selectall").checked;
		}
	}
}


function setSortNum(tableName,uuidFiledName,uuid,sortField,obj){
	//alert(uuid+" sortNum:"+$(obj).val());
	var sortNum = $(obj).val();
	
	for(var i=0; i<sortNum.length; i++) {
		if(sortNum.charCodeAt(i)<48 || sortNum.charCodeAt(i)>57){
             $(obj).val("");
             alert("请输入数字!");
             return;
		}
	}
	
	$.ajax({
			type: "POST", url: "<%=path%>/back/InfoRecommend?method=setSortNum&tableName="+tableName+"&uuidFiledName="+uuidFiledName+"&uuid="+uuid+"&sortField="+sortField+"&sortNum="+sortNum,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function(msg){
				//alert("操作成功!");
				doSearch();
			}
	 });
}


function viewKjcg(kjcgId,title)
{
	var dlg = new J.ui.dialog(
	{ id:'handledemand',
         title:'科技成果详细信息',
         range:true,
         btns:true,
         page:'<%=path%>/achieve/infoForBack.jsp?kjcgid='+kjcgId+'&title='+title,
         width:600,
         height:500,
         windowObj:window
       });
	dlg.ShowDialog();
}





</script>

</head>
<body>
<form id="seaForm" name="seaForm" method="post" action="<%=path%>/back/InfoRecommend?method=kjcgInfoList" >
	<div class="titleDiv">
  <table width="100%" cellpadding="0" cellspacing="0" border="0" style="text-align:left;">
    <tr>
      <td class="box_top_left">&nbsp;</td>
      <td class="box_top_center">科技成果信息推荐</td>
      <td class="box_top_right">&nbsp;</td>
    </tr>
  </table>
</div>
<div class="infoDiv">
  <table border="0" cellpadding="0" cellspacing="0" class="trHeightTable">
    <tr>
      <td class="leftTipArea">成果名称</td>
      <td><input id="keyword" name="keyword" value="<%=searchRcd.getString("KEYWORD","")%>" class="textInput" style="width:120px;"/></td>
      <td class="leftTipArea">完成单位</td>
      <td>
      	  <input id="FINISHUNIT" name="FINISHUNIT" value="<%=searchRcd.getString("FINISHUNIT","")%>" class="textInput" style="width:120px;"/>  	  </td>
      <td class="leftTipArea">类别</td>
	  <td>
	  <div class="select"><div><select name="KJCG_ITEM_CGLB" id="KJCG_ITEM_CGLB">
	  	   <option value="">请选择</option>
	  <%
	  	for(int i=0;i<cblb.size();i++){
	  		Record cblbRecord = cblb.get(i);
	  %>
      		<option <%=searchRcd.getString("KJCG_ITEM_CGLB","").equals(cblbRecord.getString("OPTIONVALUE",""))?"selected":""%> value="<%=cblbRecord.getString("OPTIONVALUE","")%>"><%=cblbRecord.getString("OPTIONNAME","")%></option>
       <%
       }
       %>
       </select></div></div>      </td>
      <td style="padding-left:25px;"></td>
    </tr>
    <tr>
      <td class="leftTipArea">年份</td>
      <td >
      	  <input id="SEARCHYEAR" name="SEARCHYEAR" readonly="readonly" class="textInput" value="<%=searchRcd.getString("SEARCHYEAR","")%>" style="width:120px;cursor:hand;" onclick="WdatePicker({dateFmt:'yyyy'})"/>      </td>
      <td class="leftTipArea">推荐到频道</td>
      <td>
      <div class="select"><div>
       <select name="CHANNELSHOW" id="CHANNELSHOW">
	  	   <option value="">请选择</option>
           <option value="1" <%if("1".equals(searchRcd.getString("CHANNELSHOW"))){%>selected<%}%>>是</option>
           <option value="0" <%if("0".equals(searchRcd.getString("CHANNELSHOW"))){%>selected<%}%>>否</option>
      </select>
      
      </div></div>      </td>
      <td class="leftTipArea">推荐到首页</td>
      <td>
	  <div class="select"><div>
     <select name="HOMEPAGESHOW" id="HOMEPAGESHOW">
	  	   <option value="">请选择</option>
           <option value="1" <%if("1".equals(searchRcd.getString("HOMEPAGESHOW"))){%>selected<%}%>>是</option>
           <option value="0" <%if("0".equals(searchRcd.getString("HOMEPAGESHOW"))){%>selected<%}%>>否</option>
      </select>
      </div></div></td>
      <td style="padding-left:5px;"><a href="javascript:doSearch();" class="imgButton"><span>查询</span></a></td>
    </tr>
  </table>
</div>

</form>

<div class="titleDiv">
  <table width="100%" cellpadding="0" cellspacing="0" border="0" style="text-align:left;">
    <tr>
      <td class="box_top_left" width="2">&nbsp;</td>
      <td class="box_top_center">查询结果列表</td>
      <td class="box_top_right" width="2">&nbsp;</td>
    </tr>
  </table>
</div>

<div class="contentBox">
    <table class="osTable" cellpadding="0" cellspacing="0" border="0" style="width:100%">
      <thead>
        <tr >
          <th  width="8%"><input type="checkbox" id="selectall" name="selectall" onclick="javascript:_selectall();" value=""/>选择</th>
          <th  width="17%">项目名称</th>
          <th  width="17%">完成单位</th>
          <th  width="10%">类别</th>
          <th  width="8%">年份</th>
          <th  width="10%">推荐到频道</th>
          <th  width="10%">频道排序号</th>
          <th  width="10%">推荐到首页</th>
          <th  width="10%">首页排序号</th>
        </tr>
      </thead>
      <tbody>
      	<%
      	int i=0;
      	for(i=0;i<kjcgInfoSet.size();i++){
      		Record kjcgRecord = kjcgInfoSet.get(i);
      		String showStr="";
      	%>
	        <tr >
	          <td><input type="checkbox" name="uuids" value="<%=kjcgRecord.getString("KJCGID","")%>"/></td>
	          <td><a href="#2012" onclick="viewKjcg('<%=kjcgRecord.getString("KJCGID","")%>','<%=kjcgRecord.getString("KJCG_ITEM_3","")%>');"><%=kjcgRecord.getString("KJCG_ITEM_3","")%></a></td>
	          <td >
		          <%=kjcgRecord.getString("UNIT_NAME","")%>	          </td>
	          <td >
	          	 <%
	          	  	 
	          		 showStr=kjcgRecord.getString("KJCG_ITEM_CGLB","");
			         if(!kjcgRecord.getString("KJCG_ITEM_CGLB","").equals("")){
		          	 	showStr = (String)fildOptionMap.get("ITEM_CGLB"+kjcgRecord.getString("KJCG_ITEM_CGLB",""));
		          	 }
	          	 %>
	             <%=showStr%>	          	</td>
	          <td ><%=kjcgRecord.getString("KJCG_ITEM_YEAR")%></td>
	          <td >
	             <%=!kjcgRecord.getString("CHANNELSHOW","").equals("")&&!kjcgRecord.getString("CHANNELSHOW","").equals("0")?"是":"否"%>
	          </td>
	          <td>
	          		<%if(!kjcgRecord.getString("CHANNELSHOW","").equals("")&&!kjcgRecord.getString("CHANNELSHOW","").equals("0")){%>
	          			<input id="CHANNELSORTNUM" name="CHANNELSORTNUM" class="textInput" style="width:40px;" value="<%=kjcgRecord.getString("CHANNELSORTNUM","")%>" onchange="setSortNum('T_KJCG','KJCGID','<%=kjcgRecord.getString("KJCGID","")%>','CHANNELSORTNUM',this)"/>
	          		<%}%>
	          </td>
	          <td >
	             <%=!kjcgRecord.getString("HOMEPAGESHOW","").equals("")&&!kjcgRecord.getString("HOMEPAGESHOW","").equals("0")?"是":"否"%>
	          </td>
	          <td>
	          		<%if(!kjcgRecord.getString("HOMEPAGESHOW","").equals("")&&!kjcgRecord.getString("HOMEPAGESHOW","").equals("0")){%>
	          			<input id="HOMEPAGESORTNUM" name="HOMEPAGESORTNUM" class="textInput" style="width:40px;" value="<%=kjcgRecord.getString("HOMEPAGESORTNUM","")%>" onchange="setSortNum('T_KJCG','KJCGID','<%=kjcgRecord.getString("KJCGID","")%>','HOMEPAGESORTNUM',this)"/>
	          		<%}%>
	          </td>
	        </tr>
	        <%}
	        
	         for(int j=0;j<pagingInfo.getPageSize()-kjcgInfoSet.size();j++){ %>
					<tr>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
					</tr>
				<%
			}%>
      </tbody>
    </table>


 <div  class="navRightDiv" style="width:100%;text-align:right;padding-right:10px;">
	<jsp:include flush="true" page="/common/paging.jsp"></jsp:include>
</div>

<div class="navDiv" style="height:30px;">
	    <div class="navLeftDiv" style="">
		    <a href="javascript:changeKjcgStatus('CHANNELSHOW','1');" class="imgButton" ><span>推荐到频道</span></a>
		    <a href="javascript:changeKjcgStatus('HOMEPAGESHOW','1');" class="imgButton" ><span>推荐到首页</span></a>
		    <a href="javascript:changeKjcgStatus('CHANNELSHOW','0');" class="imgButton" ><span>取消频道推荐</span></a>
		    <a href="javascript:changeKjcgStatus('HOMEPAGESHOW','0');" class="imgButton" onclick="" ><span>取消首页推荐</span></a>
	    </div>
	</div>
</div>

</body> 
</html>